package com.tpo.jnotes.base.logging;


import java.io.PrintWriter;
import java.io.StringWriter;

public class BLogging {
	  private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(BLogging.class.getName()); 
//	  	TRACE, DEBUG, INFO, WARN, ERROR, FATAL
	  
	  static {
	  	logger.info("Logger created. Log level = " + logger.getEffectiveLevel());
	  }
	  
	  public static void trace(String message){
	  	logger.trace("<TRACE> " + message);  	
	  }
	  
	  public static void debug(String message){
	  	logger.debug("<DEBUG> " + message);  	
	  }
	  
	  public static void info(String message){
	  	logger.info("<INFO> " + message);  	
	  }
	  
	  public static void warn(String message){
	  	logger.warn("<WARN> " + message);  	
	  }
	  
	  public static void error(String message){
	  	logger.error("<ERROR> " + message);  	
	  }

	  public static void fatal(String message){
	  	logger.fatal("<FATAL> " + message);  	
	  }

		public static void fatal(Throwable ex) {
			StringWriter stackTrace = new StringWriter();
			PrintWriter printWriter;
			printWriter = new PrintWriter(stackTrace);
			ex.printStackTrace(printWriter);
			fatal("<EXCEPTION> " + stackTrace);	
		}   
}
